<template>
	<view>
		<view class="history" v-if="hisSearchList.length">
			<view class="history_title">
				<view>
					<image src="../../static/images/icon_ss_sousuo.png" mode=""></image>
					<text>历史搜索</text>
				</view>
				<view @click="del">
					<image src="../../static/images/icon_ss_shanchu.png" mode=""></image>
				</view>
			</view>
			<view class="history_box" >
				<view 
				class="history_item" 
				v-for="(item,index) in hisSearchList"
				:key="item.id"
				:class="index%2 == 1?'item':''"  @click="handText(item.content)">
					{{item.content}}
				</view>
			</view>
		</view>
		
		<view class="history">
			<view class="history_title">
				<view>
					<image src="../../static/images/icon_ss_sousuo.png" mode=""></image>
					<text>大家都在搜</text>
				</view>
			</view>
			<view class="history_box">
				<view 
				class="history_item" 
				v-for="(item,index) in hotSearchList"
				:key="item.id"
				:class="index%2 == 1?'item':''" @click="handText(item.content)">
					{{item.content}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { getSearchlog,deleteSearch } from '@/common/api/search.js'
	export default {
		props:['hotSearchList','hisSearchList'],
		
		data() {
			return {
				
			}
		},
		created() {
		},
		methods:{
			handText(text) {
				this.$emit('search',text);
			},
			del() {
				deleteSearch().then(res => {
					console.log('ressssss',res);
					this.$emit('del');
				})
				console.log('11111111');
			}
		}
	}
</script>

<style lang="scss" scoped>
	.history {
		width: 100%;
		margin-top: 48rpx;
		.history_title {
			display: flex;
			justify-content: space-between;
			>view {
				display: flex;
				align-items: center;
				font-size: 28rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				color: #444444;
				>image {
					width: 30rpx;
					height: 30rpx;
				}
				>text {
					margin-left: 16rpx;
				}
			}
			
		}
		.history_box {
			width: 100%;
			padding-right:33rpx;
			box-sizing: border-box;
			margin-top: 16rpx;
			display: flex;
			flex-wrap: wrap;
			
			.history_item {
				width: 264rpx;
				font-size: 30rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #444444;
				white-space: nowrap; 
				text-overflow:ellipsis; 
				overflow:hidden; 
				margin-top: 16rpx;
			}
			.item {
				margin-left: 108rpx;
			}
		}
	}
</style>